package maquinasam.sam;
import java.util.Arrays;
import java.util.ArrayList;

public class Primitiva {
	public static final byte ID = 1;
	public static final byte NOT = 2;
	public static final byte AND = 3;
	public static final byte OR = 4;
	public static final byte INC = 5;
	public static final byte DEC = 6;
	public static final byte NEG = 7;
	public static final byte ADD = 8;
	public static final byte SUB = 9;
	public static final byte MULT = 10;
	public static final byte DIV = 11;
	public static final byte MOD = 12;
	public static final byte LT = 13;
	public static final byte LE = 14;
	public static final byte GT = 15;
	public static final byte GE = 16;
	public static final byte EQ = 17;
	public static final byte NE = 18;
	public static final byte TO21 = 19;
	public static final byte TO22 = 20;
	public static final byte NEW = 21;
	public static final byte FREE = 22;
	public static final byte GET = 23;
	public static final byte PUT = 24;
	
	private static String[] primitiveStrings = { "id", "not", "and", "or", "inc",
		"dec", "neg", "add", "sub", "mult", "div", "mod", "lt", "le", "gt", "ge",
		"eq", "ne", "to21", "to22", "new", "free", "get", "put" };
	
	private static ArrayList<String> primitiveArray = 
			new ArrayList<String>(Arrays.asList(primitiveStrings));
	
	public static byte getPrimitiveID(String str) {
		return (byte) (primitiveArray.indexOf(str) + 1);
	}
	
	public static String getPrimitiveStr(int id) {
		return primitiveStrings[id - 1];
	}
}

// Implementar la interfaz con clases separadas para cada primitiva?
// Quizas meterlas en un paquete?